Skip to content

Add per-fetch prompt cache control cache_ttl_seconds (0072)#172

Merged
chris-colinsky merged 5 commits into
mainfrom
feature/0072-prompt-cache-ttl
Jun 19, 2026
Merged

Add per-fetch prompt cache control cache_ttl_seconds (0072)#172
chris-colinsky merged 5 commits into
mainfrom
feature/0072-prompt-cache-ttl

Conversation

@chris-colinsky

Copy link
Copy Markdown
Member

Summary

Implements proposal 0072 (spec v0.63.0): a per-fetch cache_ttl_seconds read-side cache control on the prompt-management surface, and folds in the v0.63.1 patch (pipeline-utilities coverage fixtures 070/071) in the same pin advance. Pins the spec submodule v0.62.0 -> v0.63.1.

What changed

  • cache_ttl_seconds control. PromptBackend.fetch, PromptManager.fetch, and PromptManager.get gain an optional cache_ttl_seconds: None preserves current behavior, 0 forces a fresh read past any client-side cache, and N > 0 bounds a served entry's staleness to N seconds. A negative value is rejected at the manager. It is a read-side control: it governs which cached entry may be served, not whether or how results are cached.
  • Bundled backends. The filesystem backend is cacheless and ignores the control; the langfuse backend forwards it to the Langfuse SDK's get_prompt cache (which takes cache_ttl_seconds natively, mapping None / 0 / N cleanly).
  • Conformance. A caching prompt-backend harness primitive (conformance-adapter §6.8: source_read_count plus a controllable advance_clock) drives fixtures 033/034. The v0.63.1 patch fixtures 070/071 (coverage for already-implemented 0069 / 0070 behavior, no new proposal) are wired into the pipeline-utilities and checkpoint runners.
  • Docs. The prompt-management concepts page documents the control with examples.

Design notes

The langfuse forwarding is slightly beyond the spec's strict minimum (which only requires threading the param plus cacheless-backend no-op), but the Langfuse SDK's get_prompt caches and accepts the param natively, so forwarding makes OA's control actually govern langfuse prompt caching rather than silently ignoring it. python ships no production caching backend (the caching primitive is harness-only); the bundled backends are cacheless, matching §5's "cacheless backends treat it as a no-op."

Testing

  • Conformance fixtures 033/034 (default-serve, force-fresh, bounded-staleness via the controllable clock) and the wired 070/071.
  • Unit tests: negative-value rejection, and the langfuse backend forwarding the value to the SDK.
  • Full suite green (1345 passed); pyright and mkdocs clean.

Notes

  • The 0.15.0 changelog date is tentative pending the release tag.

Advance the spec submodule pin v0.62.0 -> v0.63.1 to absorb accepted
proposal 0072 (per-fetch cache_ttl_seconds prompt-cache control) at
v0.63.0 plus the v0.63.1 patch (pipeline-utilities coverage fixtures
070/071). Updates __spec_version__, the pyproject spec_version, the
smoke-test assertion, and regenerates the bundled AGENTS.md.

conformance.toml records 0072 as implemented; the v0.63.1 fixtures add
no proposal entry (coverage for the already-implemented 0069 / 0070).
PromptBackend.fetch, PromptManager.fetch, and PromptManager.get gain an
optional cache_ttl_seconds read-side control: None preserves current
behavior, 0 forces a fresh read past any client-side cache, and N > 0
bounds a served entry's staleness to N seconds; a negative value is
rejected at the manager. It governs only which cached entry may be
served, not whether or how results are cached.

The bundled filesystem backend is cacheless and ignores it; the langfuse
backend forwards it to the SDK's get_prompt cache. Every backend
implementation (mocks + example backends) accepts the new param.

Conformance: a caching prompt-backend harness primitive (source_read_count
plus a controllable advance_clock) drives fixtures 033/034; unit tests
cover the negative-value rejection and the langfuse forwarding.
Wire the v0.63.1 coverage fixtures into the conformance runners: 071
(fan-out degrade strict-reducer-raise) joins the failure-isolation set
in the pipeline-utilities runner, and 070 (crash-injection after_node
resume) joins the checkpoint runner alongside 067. python's behavior is
already conformant (unit-tested in v0.14.0); this is harness selection.
Document the cache_ttl_seconds read-side control in the prompt-management
concepts page, and add the 0.15.0 changelog entry plus advance the
cycle's spec-pin bullet to v0.63.1 (proposal 0072 + the 070/071 patch).
Copilot AI review requested due to automatic review settings June 19, 2026 22:33
Comment thread src/openarmature/prompts/backends/langfuse.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements spec proposal 0072 by adding a per-fetch read-side prompt cache control (cache_ttl_seconds) across the prompt-management surface, and advances the pinned spec version to v0.63.1 (including wiring the v0.63.1 conformance coverage fixtures 070/071).

Changes:

  • Add cache_ttl_seconds to PromptBackend.fetch, PromptManager.fetch, and PromptManager.get, with manager-side validation for negative values.
  • Forward cache_ttl_seconds through the Langfuse backend to the Langfuse SDK; accept-and-ignore it in the cacheless filesystem backend.
  • Extend the conformance prompt-management harness to support a caching primitive and backend end-state assertions; update spec/version documentation and changelog.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unit/test_prompts.py Updates backend test doubles for new fetch signature; adds unit test for negative TTL rejection.
tests/unit/test_prompts_langfuse.py Adds coverage asserting Langfuse backend forwards cache_ttl_seconds to the SDK.
tests/test_smoke.py Updates spec version assertion to 0.63.1.
tests/conformance/test_prompt_management.py Adds caching primitive + clock controls; wires direct-backend cache control and backend state assertions.
tests/conformance/test_pipeline_utilities.py Wires fixture 071 into failure-isolation fixture set for v0.63.1 patch coverage.
tests/conformance/test_observability_langfuse.py Updates mock prompt backend signature for protocol conformance.
tests/conformance/test_checkpoint.py Wires fixture 070 into checkpoint fixture set for v0.63.1 patch coverage.
tests/conformance/harness/prompt_management.py Extends fixture schema with caching primitive controls and expected backend state.
src/openarmature/prompts/manager.py Adds cache_ttl_seconds to fetch/get and validates/rejects negative values.
src/openarmature/prompts/backends/langfuse.py Forwards cache_ttl_seconds into Langfuse SDK get_prompt call path.
src/openarmature/prompts/backends/filesystem.py Accepts (and ignores) cache_ttl_seconds to match updated protocol.
src/openarmature/prompts/backend.py Updates PromptBackend protocol and documents cache control semantics.
src/openarmature/AGENTS.md Updates bundled agent guide spec-version references to 0.63.1.
src/openarmature/init.py Bumps __spec_version__ to 0.63.1.
pyproject.toml Bumps [tool.openarmature].spec_version to 0.63.1.
examples/langfuse-observability/main.py Updates example backend signature for protocol conformance.
examples/chat-with-multimodal/main.py Updates example backend signature for protocol conformance.
docs/concepts/prompts.md Documents cache_ttl_seconds behavior and examples.
conformance.toml Records proposal 0072 as implemented and notes v0.63.1 fixture wiring.
CHANGELOG.md Adds changelog entry for cache_ttl_seconds and updates spec pin note to v0.63.1.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/conformance/test_prompt_management.py
PR #172 review: _run_call's manager-target fetch/get dropped
call.cache_ttl_seconds, so target: manager fixtures couldn't exercise
the manager's threading (033/034 use direct-backend targets, so they
were unaffected). Forward the control on both, matching the
direct-backend path.
@chris-colinsky chris-colinsky merged commit 3c85bdf into main Jun 19, 2026
6 checks passed
@chris-colinsky chris-colinsky deleted the feature/0072-prompt-cache-ttl branch June 19, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants